#!/bin/bash
CURRENT_PATH=$(pwd);
ROOT_PATH=$(cd `dirname $0`/; pwd);

RUN_PATH=${ROOT_PATH}-ing

cd ../;

# delete
rm -rf ${RUN_PATH}

# copy
cp -r ${ROOT_PATH} ${RUN_PATH}

cd ${RUN_PATH}
pwd

# restart
if [[ ${CURRENT_NODE} = ${FIRST_NODE} ]]
then
    npx pm2 startOrRestart --hp ${RUN_PATH} ${RUN_PATH}/pm2.json
fi